#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>

int main()
{
    pid_t pid = fork();
    if(pid<0){
        perror("fork");
    }else if(pid==0){
        int count = 0;
        sleep(1);
        int *lp = NULL;
        *lp = 10;
        while(1){
            printf("i am child pid=%d,ppid=%d\n",getpid(),getppid());
        }
        exit(10);
    }else if(pid>0){
        printf("begin----->i am father pid=%d,ppid=%d\n",getpid(),getppid());
        int status;
        wait(&status);
        printf("sig_code:%d\n",status & 0x7F);
        printf("coredump_code:%d\n",(status>>7) & 0x1);
        while(1){
            printf("i am father child pid=%d,ppid=%d\n",getpid(),getppid());
            sleep(1);
        }
    }

    return 0;
}